import request from "@/utils/request.js";

const PREFIX = '/user/theme'
// 专题数据
export const mockThemes = [
  {
    id: 1,
    title: '母亲节专题',
    subtitle: '感恩母爱',
    description: '母亲节特别策划，精选感恩礼物',
    image: '/themes/mothers-day.jpg',
    bannerImage: '/themes/mothers-day-banner.jpg',
    products: [1, 2]  // 商品ID列表
  }
]

// 获取专题列表
export const getThemes = async () => {
  await new Promise(resolve => setTimeout(resolve, 300))
  return mockThemes
}

// 获取专题详情
export const getTheme = async (id) => {
  return request(`${PREFIX}/${id}`)
}

// 获取专题商品
export const getThemeProducts = async (id) => {
  await new Promise(resolve => setTimeout(resolve, 300))
  const theme = mockThemes.find(t => t.id === Number(id))
  if (!theme) return []

  return theme.products.map(pid =>
    mockProducts.find(p => p.id === pid)
  ).filter(Boolean)
}
